using System;
using System.Text;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using Oracle.ManagedDataAccess.Client;
using OracleInternal.Common;

namespace Oracle.ManagedDataAccess.Types
{
	[Serializable]
	[XmlSchemaProvider("GetXsdType")]
	public struct OracleIntervalDS : IComparable, INullable, IXmlSerializable
	{
		private static uint INTERVALDSOFFSET = 60u;

		private static uint INTERVALDAYOFFSET = 2147483648u;

		private static int MAXLEADPREC = 9;

		private static uint INTERVALDAYOFFSET_REGIDFLAG = 32768u;

		private static uint LDIREGIDSET = 181u;

		internal static uint LDIREGIDFLAG = 120u;

		internal const short MaxArrSize = 11;

		internal const byte IDSType = 10;

		internal const byte DAY = 2;

		internal const byte HOUR = 3;

		internal const byte MINUTE = 4;

		internal const byte SECOND = 5;

		internal const byte MILLISECOND = 6;

		internal const byte FSECOND = 7;

		internal const byte MaxStrLen = byte.MaxValue;

		private bool m_bNotNull;

		private byte m_dayPrec;

		private byte m_fSecondPrec;

		private byte[] m_byteRepresentation;

		public static readonly OracleIntervalDS Null;

		internal int initialZoneId;

		public static readonly OracleIntervalDS MaxValue = new OracleIntervalDS(999999999, 23, 59, 59, 999999999);

		public static readonly OracleIntervalDS MinValue = new OracleIntervalDS(-999999999, -23, -59, -59, -999999999);

		public static readonly OracleIntervalDS Zero = new OracleIntervalDS(0, 0, 0, 0, 0);

		public byte[] BinData
		{
			get
			{
				if (m_bNotNull)
				{
					byte[] array = new byte[11];
					Array.Copy(m_byteRepresentation, array, 11);
					return array;
				}
				throw new OracleNullValueException();
			}
		}

		public bool IsNull => !m_bNotNull;

		public TimeSpan Value
		{
			get
			{
				if (m_bNotNull)
				{
					return GetTimeSpan(m_byteRepresentation, OracleDbType.IntervalDS);
				}
				throw new OracleNullValueException();
			}
		}

		public int Days
		{
			get
			{
				if (m_bNotNull)
				{
					return GetIDSData(m_byteRepresentation, 2);
				}
				throw new OracleNullValueException();
			}
		}

		public int Hours
		{
			get
			{
				if (m_bNotNull)
				{
					return GetIDSData(m_byteRepresentation, 3);
				}
				throw new OracleNullValueException();
			}
		}

		public int Minutes
		{
			get
			{
				if (m_bNotNull)
				{
					return GetIDSData(m_byteRepresentation, 4);
				}
				throw new OracleNullValueException();
			}
		}

		public int Seconds
		{
			get
			{
				if (m_bNotNull)
				{
					return GetIDSData(m_byteRepresentation, 5);
				}
				throw new OracleNullValueException();
			}
		}

		public double Milliseconds
		{
			get
			{
				if (m_bNotNull)
				{
					return GetIDSData(m_byteRepresentation, 7) / 1000000;
				}
				throw new OracleNullValueException();
			}
		}

		public int Nanoseconds
		{
			get
			{
				if (m_bNotNull)
				{
					return GetIDSData(m_byteRepresentation, 7);
				}
				throw new OracleNullValueException();
			}
		}

		public double TotalDays
		{
			get
			{
				if (m_bNotNull)
				{
					GetIDSData(m_byteRepresentation, out var days, out var hours, out var minutes, out var seconds, out var fseconds);
					return (double)days + (double)hours / 24.0 + (double)minutes / 1440.0 + (double)seconds / 86400.0 + (double)fseconds / 86400000000000.0;
				}
				throw new OracleNullValueException();
			}
		}

		internal byte[] InternalByteRepresentation => m_byteRepresentation;

		public OracleIntervalDS(byte[] binData)
			: this(binData, bCopyData: true)
		{
		}

		public OracleIntervalDS(int days, int hours, int minutes, int seconds, int nanoseconds)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ctor);
			}
			try
			{
				if (Interval.IsValidDS(days, hours, minutes, seconds, nanoseconds))
				{
					m_bNotNull = true;
					initialZoneId = 0;
					m_fSecondPrec = 9;
					m_dayPrec = 9;
					m_byteRepresentation = new byte[11];
					days += (int)INTERVALDAYOFFSET;
					m_byteRepresentation[0] = RepConversion.RightShiftFirstNibble(days);
					m_byteRepresentation[1] = RepConversion.RightShiftSecondNibble(days);
					m_byteRepresentation[2] = RepConversion.RightShiftThirdNibble(days);
					m_byteRepresentation[3] = RepConversion.RightShiftFourthNibble(days);
					m_byteRepresentation[4] = (byte)(hours + INTERVALDSOFFSET);
					m_byteRepresentation[5] = (byte)(minutes + INTERVALDSOFFSET);
					m_byteRepresentation[6] = (byte)(seconds + INTERVALDSOFFSET);
					int val = nanoseconds + (int)INTERVALDAYOFFSET;
					m_byteRepresentation[7] = RepConversion.RightShiftFirstNibble(val);
					m_byteRepresentation[8] = RepConversion.RightShiftSecondNibble(val);
					m_byteRepresentation[9] = RepConversion.RightShiftThirdNibble(val);
					m_byteRepresentation[10] = RepConversion.RightShiftFourthNibble(val);
					return;
				}
				throw new ArgumentOutOfRangeException();
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ctor);
				}
			}
		}

		public OracleIntervalDS(int days, int hours, int minutes, int seconds, double milliseconds)
			: this(days, hours, minutes, seconds, (int)(milliseconds * 1000000.0))
		{
		}

		public OracleIntervalDS(TimeSpan data)
			: this(data.Days, data.Hours, data.Minutes, data.Seconds, (int)(data.Ticks - data.Days * 864000000000L - data.Hours * 36000000000L - (long)data.Minutes * 600000000L - (long)data.Seconds * 10000000L) * 100)
		{
		}

		public OracleIntervalDS(double totalDays)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ctor);
			}
			try
			{
				decimal num = (decimal)totalDays;
				int num2 = (int)num;
				decimal num3 = (num - (decimal)num2) * 24m;
				int num4 = (int)num3;
				decimal num5 = (num3 - (decimal)num4) * 60m;
				int num6 = (int)num5;
				decimal num7 = (num5 - (decimal)num6) * 60m;
				int num8 = (int)num7;
				int num9 = (int)((num7 - (decimal)num8) * 1000000000m);
				if (Interval.IsValidDS(num2, num4, num6, num8, num9))
				{
					m_bNotNull = true;
					initialZoneId = 0;
					m_fSecondPrec = 9;
					m_dayPrec = 9;
					m_byteRepresentation = new byte[11];
					num2 += (int)INTERVALDAYOFFSET;
					m_byteRepresentation[0] = RepConversion.RightShiftFirstNibble(num2);
					m_byteRepresentation[1] = RepConversion.RightShiftSecondNibble(num2);
					m_byteRepresentation[2] = RepConversion.RightShiftThirdNibble(num2);
					m_byteRepresentation[3] = RepConversion.RightShiftFourthNibble(num2);
					m_byteRepresentation[4] = (byte)(num4 + INTERVALDSOFFSET);
					m_byteRepresentation[5] = (byte)(num6 + INTERVALDSOFFSET);
					m_byteRepresentation[6] = (byte)(num8 + INTERVALDSOFFSET);
					int val = num9 + (int)INTERVALDAYOFFSET;
					m_byteRepresentation[7] = RepConversion.RightShiftFirstNibble(val);
					m_byteRepresentation[8] = RepConversion.RightShiftSecondNibble(val);
					m_byteRepresentation[9] = RepConversion.RightShiftThirdNibble(val);
					m_byteRepresentation[10] = RepConversion.RightShiftFourthNibble(val);
					return;
				}
				throw new OverflowException("totalDays");
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ctor);
				}
			}
		}

		public OracleIntervalDS(string intervalStr)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ctor);
			}
			try
			{
				if (intervalStr == null)
				{
					throw new ArgumentNullException("intervalStr");
				}
				if (intervalStr.Length == 0)
				{
					throw new FormatException("intervalStr");
				}
				m_bNotNull = true;
				initialZoneId = 0;
				m_fSecondPrec = 9;
				m_dayPrec = 9;
				m_byteRepresentation = null;
				m_byteRepresentation = ToBytes(intervalStr);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ctor);
				}
			}
		}

		internal OracleIntervalDS(byte[] binData, int dayPrecision, int fsecondPrecision, bool bCopyData = true)
			: this(binData, bCopyData)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ctor);
			}
			try
			{
				GetIDSData(m_byteRepresentation, out var days, out var hours, out var minutes, out var seconds, out var fseconds);
				int num = 0;
				num = ((days >= 0) ? days : (-days));
				if (num != 0 && num.ToString().Length > dayPrecision)
				{
					throw new OverflowException("binData");
				}
				m_dayPrec = (byte)dayPrecision;
				m_fSecondPrec = (byte)fsecondPrecision;
				fseconds = Convert.ToInt32(Math.Round((double)fseconds / 1000000000.0, fsecondPrecision) * 1000000000.0);
				if (fseconds < 1000000000 && fseconds > -999999998)
				{
					fseconds += (int)INTERVALDAYOFFSET;
					m_byteRepresentation[7] = RepConversion.RightShiftFirstNibble(fseconds);
					m_byteRepresentation[8] = RepConversion.RightShiftSecondNibble(fseconds);
					m_byteRepresentation[9] = RepConversion.RightShiftThirdNibble(fseconds);
					m_byteRepresentation[10] = RepConversion.RightShiftFourthNibble(fseconds);
					return;
				}
				if (fseconds > 999999999)
				{
					fseconds = 0;
					seconds++;
				}
				else if (fseconds < -999999999)
				{
					fseconds = 0;
					seconds--;
				}
				if (seconds > 59)
				{
					seconds = 0;
					minutes++;
				}
				else if (seconds < -59)
				{
					seconds = 0;
					minutes--;
				}
				if (minutes > 59)
				{
					minutes = 0;
					hours++;
				}
				else if (minutes < -59)
				{
					minutes = 0;
					hours--;
				}
				if (hours > 23)
				{
					hours = 0;
					days++;
				}
				else if (hours < -23)
				{
					hours = 0;
					days--;
				}
				if (days > 999999999 || days < -999999999)
				{
					throw new OverflowException("binData");
				}
				days += (int)INTERVALDAYOFFSET;
				m_byteRepresentation[0] = RepConversion.RightShiftFirstNibble(days);
				m_byteRepresentation[1] = RepConversion.RightShiftSecondNibble(days);
				m_byteRepresentation[2] = RepConversion.RightShiftThirdNibble(days);
				m_byteRepresentation[3] = RepConversion.RightShiftFourthNibble(days);
				m_byteRepresentation[4] = (byte)(hours + INTERVALDSOFFSET);
				m_byteRepresentation[5] = (byte)(minutes + INTERVALDSOFFSET);
				m_byteRepresentation[6] = (byte)(seconds + INTERVALDSOFFSET);
				fseconds += (int)INTERVALDAYOFFSET;
				m_byteRepresentation[7] = RepConversion.RightShiftFirstNibble(fseconds);
				m_byteRepresentation[8] = RepConversion.RightShiftSecondNibble(fseconds);
				m_byteRepresentation[9] = RepConversion.RightShiftThirdNibble(fseconds);
				m_byteRepresentation[10] = RepConversion.RightShiftFourthNibble(fseconds);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ctor);
				}
			}
		}

		internal OracleIntervalDS(byte[] binData, bool bCopyData)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ctor);
			}
			try
			{
				if (binData == null)
				{
					throw new ArgumentNullException("binData");
				}
				m_bNotNull = true;
				initialZoneId = 0;
				m_fSecondPrec = 9;
				m_dayPrec = 9;
				if (binData.Length != 11)
				{
					throw new ArgumentException("binData");
				}
				if (bCopyData)
				{
					m_byteRepresentation = new byte[11];
					Array.Copy(binData, m_byteRepresentation, 11);
				}
				else
				{
					m_byteRepresentation = binData;
				}
				GetIDSData(m_byteRepresentation, out var days, out var hours, out var minutes, out var seconds, out var fseconds);
				if (!Interval.IsValidDS(days, hours, minutes, seconds, fseconds))
				{
					throw new OverflowException("binData");
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ctor);
				}
			}
		}

		public static bool Equals(OracleIntervalDS value1, OracleIntervalDS value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.Equals);
			}
			try
			{
				return InternalTypes.CompareNull(!value1.m_bNotNull, !value2.m_bNotNull) switch
				{
					CompareNullEnum.BothNull => true, 
					CompareNullEnum.BothNotNull => value1.CompareTo(value2) == 0, 
					_ => false, 
				};
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.Equals, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.Equals);
				}
			}
		}

		public static bool GreaterThan(OracleIntervalDS value1, OracleIntervalDS value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.GreaterThan);
			}
			try
			{
				return value1.CompareTo(value2) > 0;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.GreaterThan, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.GreaterThan);
				}
			}
		}

		public static bool GreaterThanOrEqual(OracleIntervalDS value1, OracleIntervalDS value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.GreaterThanOrEqual);
			}
			try
			{
				return value1.CompareTo(value2) >= 0;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.GreaterThanOrEqual, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.GreaterThanOrEqual);
				}
			}
		}

		public static bool LessThan(OracleIntervalDS value1, OracleIntervalDS value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.LessThan);
			}
			try
			{
				return value1.CompareTo(value2) < 0;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.LessThan);
				}
			}
		}

		public static bool LessThanOrEqual(OracleIntervalDS value1, OracleIntervalDS value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.LessThanOrEqual);
			}
			try
			{
				return value1.CompareTo(value2) <= 0;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.LessThanOrEqual);
				}
			}
		}

		public static bool NotEquals(OracleIntervalDS value1, OracleIntervalDS value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.NotEquals);
			}
			try
			{
				return value1.CompareTo(value2) != 0;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.NotEquals);
				}
			}
		}

		public static OracleIntervalDS Parse(string intervalStr)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.Parse);
			}
			try
			{
				return new OracleIntervalDS(intervalStr);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.Parse, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.Parse);
				}
			}
		}

		public static OracleIntervalDS SetPrecision(OracleIntervalDS value1, int dayPrecision, int fracSecPrecision)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.SetPrecision);
			}
			try
			{
				if (!value1.m_bNotNull)
				{
					throw new OracleNullValueException();
				}
				if (dayPrecision < 0 || dayPrecision > 9)
				{
					throw new ArgumentOutOfRangeException("dayPrecision");
				}
				if (fracSecPrecision < 0 || fracSecPrecision > 9)
				{
					throw new ArgumentOutOfRangeException("fracSecPrecision");
				}
				return new OracleIntervalDS(value1.InternalByteRepresentation, dayPrecision, fracSecPrecision);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.SetPrecision, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.SetPrecision);
				}
			}
		}

		public static bool operator ==(OracleIntervalDS value1, OracleIntervalDS value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorEqualTo);
			}
			try
			{
				return Equals(value1, value2);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorEqualTo);
				}
			}
		}

		public static bool operator >(OracleIntervalDS value1, OracleIntervalDS value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorGreaterThan);
			}
			try
			{
				return GreaterThan(value1, value2);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorGreaterThan);
				}
			}
		}

		public static bool operator >=(OracleIntervalDS value1, OracleIntervalDS value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorGreaterThanOrEqualTo);
			}
			try
			{
				return GreaterThanOrEqual(value1, value2);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorGreaterThanOrEqualTo);
				}
			}
		}

		public static bool operator <(OracleIntervalDS value1, OracleIntervalDS value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorLessThan);
			}
			try
			{
				return LessThan(value1, value2);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorLessThan);
				}
			}
		}

		public static bool operator <=(OracleIntervalDS value1, OracleIntervalDS value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorLessThanOrEqualTo);
			}
			try
			{
				return LessThanOrEqual(value1, value2);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorLessThanOrEqualTo);
				}
			}
		}

		public static bool operator !=(OracleIntervalDS value1, OracleIntervalDS value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorNotEqualTo);
			}
			try
			{
				return NotEquals(value1, value2);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorNotEqualTo);
				}
			}
		}

		public static OracleIntervalDS operator +(OracleIntervalDS value1, OracleIntervalDS value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorPlus);
			}
			try
			{
				if (!value1.m_bNotNull || !value2.m_bNotNull)
				{
					return Null;
				}
				int num = 0;
				GetIDSData(value1.InternalByteRepresentation, out var days, out var hours, out var minutes, out var seconds, out var fseconds);
				GetIDSData(value2.InternalByteRepresentation, out var days2, out var hours2, out var minutes2, out var seconds2, out var fseconds2);
				int num2 = fseconds + fseconds2;
				if (num2 > 999999999)
				{
					num = 1;
					num2 -= 1000000000;
				}
				else if (num2 < -999999999)
				{
					num = -1;
					num2 -= -1000000000;
				}
				int num3 = seconds + seconds2 + num;
				num = 0;
				if (num3 > 59)
				{
					num = 1;
					num3 -= 60;
				}
				else if (num3 < -59)
				{
					num = -1;
					num3 -= -60;
				}
				int num4 = minutes + minutes2 + num;
				num = 0;
				if (num4 > 59)
				{
					num = 1;
					num4 -= 60;
				}
				else if (num4 < -59)
				{
					num = -1;
					num4 -= -60;
				}
				int num5 = hours + hours2 + num;
				num = 0;
				if (num5 > 23)
				{
					num = 1;
					num5 -= 24;
				}
				else if (num5 < -23)
				{
					num = -1;
					num5 -= -24;
				}
				int num6 = days + days2 + num;
				if (num6 > 999999999 || num6 < -999999999)
				{
					throw new OverflowException();
				}
				if ((num6 >= 0 && num5 >= 0 && num4 >= 0 && num3 >= 0 && num2 >= 0) || (num6 <= 0 && num5 <= 0 && num4 <= 0 && num3 <= 0 && num2 <= 0))
				{
					return new OracleIntervalDS(num6, num5, num4, num3, num2);
				}
				return GetOracleIntervalDS(num6, num5, num4, num3, num2);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorPlus, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorPlus);
				}
			}
		}

		public static OracleIntervalDS operator -(OracleIntervalDS value1, OracleIntervalDS value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorMinus);
			}
			try
			{
				if (!value1.m_bNotNull || !value2.m_bNotNull)
				{
					return Null;
				}
				int num = 0;
				GetIDSData(value1.InternalByteRepresentation, out var days, out var hours, out var minutes, out var seconds, out var fseconds);
				GetIDSData(value2.InternalByteRepresentation, out var days2, out var hours2, out var minutes2, out var seconds2, out var fseconds2);
				int num2 = fseconds - fseconds2;
				if (num2 > 999999999)
				{
					num = 1;
					num2 -= 1000000000;
				}
				else if (num2 < -999999999)
				{
					num = -1;
					num2 -= -1000000000;
				}
				int num3 = seconds - seconds2 + num;
				num = 0;
				if (num3 > 59)
				{
					num = 1;
					num3 -= 60;
				}
				else if (num3 < -59)
				{
					num = -1;
					num3 -= -60;
				}
				int num4 = minutes - minutes2 + num;
				num = 0;
				if (num4 > 59)
				{
					num = 1;
					num4 -= 60;
				}
				else if (num4 < -59)
				{
					num = -1;
					num4 -= -60;
				}
				int num5 = hours - hours2 + num;
				num = 0;
				if (num5 > 23)
				{
					num = 1;
					num5 -= 24;
				}
				else if (num5 < -23)
				{
					num = -1;
					num5 -= -24;
				}
				int num6 = days - days2 + num;
				if (num6 > 999999999 || num6 < -999999999)
				{
					throw new OverflowException();
				}
				if ((num6 >= 0 && num5 >= 0 && num4 >= 0 && num3 >= 0 && num2 >= 0) || (num6 <= 0 && num5 <= 0 && num4 <= 0 && num3 <= 0 && num2 <= 0))
				{
					return new OracleIntervalDS(num6, num5, num4, num3, num2);
				}
				return GetOracleIntervalDS(num6, num5, num4, num3, num2);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorMinus, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorMinus);
				}
			}
		}

		public static OracleIntervalDS operator -(OracleIntervalDS value1)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorMinus);
			}
			try
			{
				if (!value1.m_bNotNull)
				{
					return Null;
				}
				GetIDSData(value1.InternalByteRepresentation, out var days, out var hours, out var minutes, out var seconds, out var fseconds);
				if ((days >= 0 && hours >= 0 && minutes >= 0 && seconds >= 0 && fseconds >= 0) || (days <= 0 && hours <= 0 && minutes <= 0 && seconds <= 0 && fseconds <= 0))
				{
					return new OracleIntervalDS(-days, -hours, -minutes, -seconds, -fseconds);
				}
				return GetOracleIntervalDS(-days, -hours, -minutes, -seconds, -fseconds);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorMinus, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorMinus);
				}
			}
		}

		public static OracleIntervalDS operator *(OracleIntervalDS value1, int multiplier)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorMultiply);
			}
			try
			{
				if (!value1.m_bNotNull)
				{
					return Null;
				}
				long num = 0L;
				long num2 = 0L;
				GetIDSData(value1.InternalByteRepresentation, out var days, out var hours, out var minutes, out var seconds, out var fseconds);
				num = (long)fseconds * (long)multiplier;
				if (num > 999999999 || num < -999999999)
				{
					num2 = num / 1000000000;
					fseconds = (int)(num % 1000000000);
				}
				else
				{
					fseconds = (int)num;
				}
				num = seconds * multiplier + num2;
				num2 = 0L;
				if (num > 59 || num < -59)
				{
					num2 = num / 60;
					seconds = (int)num % 60;
				}
				else
				{
					seconds = (int)num;
				}
				num = minutes * multiplier + num2;
				num2 = 0L;
				if (num > 59 || num < -59)
				{
					num2 = num / 60;
					minutes = (int)num % 60;
				}
				else
				{
					minutes = (int)num;
				}
				num = hours * multiplier + num2;
				num2 = 0L;
				if (num > 23 || num < -23)
				{
					num2 = num / 24;
					hours = (int)num % 24;
				}
				else
				{
					hours = (int)num;
				}
				num = (long)days * (long)multiplier + num2;
				if (num > 999999999 || num < -999999999)
				{
					throw new OverflowException();
				}
				days = (int)num;
				if ((days >= 0 && hours >= 0 && minutes >= 0 && seconds >= 0 && fseconds >= 0) || (days <= 0 && hours <= 0 && minutes <= 0 && seconds <= 0 && fseconds <= 0))
				{
					return new OracleIntervalDS(days, hours, minutes, seconds, fseconds);
				}
				return GetOracleIntervalDS(days, hours, minutes, seconds, fseconds);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorMultiply, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorMultiply);
				}
			}
		}

		public static OracleIntervalDS operator /(OracleIntervalDS value1, int divisor)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorDivide);
			}
			try
			{
				if (!value1.m_bNotNull)
				{
					return Null;
				}
				long num = 0L;
				long num2 = 0L;
				if (divisor == 0)
				{
					throw new DivideByZeroException();
				}
				GetIDSData(value1.InternalByteRepresentation, out var days, out var hours, out var minutes, out var seconds, out var fseconds);
				num = (long)days / (long)divisor;
				num2 = days % divisor;
				days = (int)num;
				long num3 = hours + num2 * 24;
				num = num3 / divisor;
				num2 = num3 % divisor;
				hours = (int)num;
				long num4 = minutes + num2 * 60;
				num = num4 / divisor;
				num2 = num4 % divisor;
				minutes = (int)num;
				long num5 = seconds + num2 * 60;
				num = num5 / divisor;
				num2 = num5 % divisor;
				seconds = (int)num;
				num = (fseconds + num2 * 1000000000) / divisor;
				fseconds = (int)num;
				if ((days >= 0 && hours >= 0 && minutes >= 0 && seconds >= 0 && fseconds >= 0) || (days <= 0 && hours <= 0 && minutes <= 0 && seconds <= 0 && fseconds <= 0))
				{
					return new OracleIntervalDS(days, hours, minutes, seconds, fseconds);
				}
				return GetOracleIntervalDS(days, hours, minutes, seconds, fseconds);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorDivide, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.OperatorDivide);
				}
			}
		}

		public static explicit operator OracleIntervalDS(string intervalStr)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ctor);
			}
			try
			{
				return new OracleIntervalDS(intervalStr);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ctor);
				}
			}
		}

		public static explicit operator TimeSpan(OracleIntervalDS value1)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.TimeSpan);
			}
			try
			{
				if (value1.m_bNotNull)
				{
					decimal num = IntervalDSToTicks(value1.InternalByteRepresentation);
					if (num < new decimal(long.MinValue) || num > new decimal(long.MaxValue))
					{
						throw new OverflowException();
					}
					return new TimeSpan((long)num);
				}
				throw new OracleNullValueException();
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.TimeSpan, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.TimeSpan);
				}
			}
		}

		public static implicit operator OracleIntervalDS(TimeSpan value1)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ctor);
			}
			try
			{
				return new OracleIntervalDS(value1);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ctor);
				}
			}
		}

		public static XmlQualifiedName GetXsdType(XmlSchemaSet schemaSet)
		{
			return new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
		}

		XmlSchema IXmlSerializable.GetSchema()
		{
			return null;
		}

		void IXmlSerializable.ReadXml(XmlReader reader)
		{
			if (reader == null)
			{
				throw new ArgumentNullException("reader");
			}
			string attribute = reader.GetAttribute("null", "http://www.w3.org/2001/XMLSchema-instance");
			if (attribute == null || !XmlConvert.ToBoolean(attribute))
			{
				attribute = reader.ReadElementString();
				if (attribute == null || attribute.Length == 0)
				{
					throw new FormatException();
				}
				m_fSecondPrec = 9;
				m_dayPrec = 9;
				m_byteRepresentation = ToBytes(attribute);
				m_bNotNull = true;
			}
			else
			{
				m_bNotNull = false;
			}
		}

		void IXmlSerializable.WriteXml(XmlWriter writer)
		{
			if (m_bNotNull)
			{
				writer.WriteString(ToString());
			}
			else
			{
				writer.WriteAttributeString("xsi", "null", "http://www.w3.org/2001/XMLSchema-instance", "true");
			}
		}

		public int CompareTo(object obj)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.CompareTo);
			}
			try
			{
				if (obj == null)
				{
					throw new ArgumentNullException("obj");
				}
				if (obj.GetType() != typeof(OracleIntervalDS))
				{
					throw new ArgumentException("obj");
				}
				OracleIntervalDS oracleIntervalDS = (OracleIntervalDS)obj;
				switch (InternalTypes.CompareNull(!m_bNotNull, !oracleIntervalDS.m_bNotNull))
				{
				case CompareNullEnum.BothNull:
					return 0;
				case CompareNullEnum.FirstNullOnly:
					return -1;
				case CompareNullEnum.SecondNullOnly:
					return 1;
				default:
				{
					byte[] internalByteRepresentation = oracleIntervalDS.InternalByteRepresentation;
					for (int i = 0; i < m_byteRepresentation.Length; i++)
					{
						if (m_byteRepresentation[i] != internalByteRepresentation[i])
						{
							if (m_byteRepresentation[i] < internalByteRepresentation[i])
							{
								return -1;
							}
							return 1;
						}
					}
					return 0;
				}
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.CompareTo, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.CompareTo);
				}
			}
		}

		public override string ToString()
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ToString);
			}
			try
			{
				if (m_bNotNull)
				{
					bool flag = true;
					GetIDSData(m_byteRepresentation, out var days, out var hours, out var minutes, out var seconds, out var fseconds);
					if (days < 0)
					{
						flag = false;
						days = -days;
						hours = -hours;
						minutes = -minutes;
						seconds = -seconds;
						fseconds = -fseconds;
					}
					else if (hours < 0)
					{
						flag = false;
						hours = -hours;
						minutes = -minutes;
						seconds = -seconds;
						fseconds = -fseconds;
					}
					else if (minutes < 0)
					{
						flag = false;
						minutes = -minutes;
						seconds = -seconds;
						fseconds = -fseconds;
					}
					else if (seconds < 0)
					{
						flag = false;
						seconds = -seconds;
						fseconds = -fseconds;
					}
					else if (fseconds < 0)
					{
						flag = false;
						fseconds = -fseconds;
					}
					string text = days.ToString();
					string text2 = fseconds.ToString();
					if (text.Length < m_dayPrec)
					{
						text = HelperClass.GetZeros(m_dayPrec - text.Length) + text;
					}
					int length = text2.Length;
					if (length < m_fSecondPrec)
					{
						text2 = HelperClass.GetZeros(m_fSecondPrec - length) + text2;
					}
					else if (length > m_fSecondPrec)
					{
						text2 = text2.Substring(0, m_fSecondPrec);
					}
					int length2 = text.Length;
					if (length2 < m_dayPrec)
					{
						text = HelperClass.GetZeros(m_dayPrec - length2) + text;
					}
					else if (length2 > m_dayPrec)
					{
						text = text2.Substring(0, m_dayPrec);
					}
					StringBuilder stringBuilder = new StringBuilder(30);
					if (flag)
					{
						stringBuilder.Append("+");
					}
					else
					{
						stringBuilder.Append("-");
					}
					if (text.Length == 0)
					{
						stringBuilder.Append("0");
					}
					else
					{
						stringBuilder.Append(text);
					}
					stringBuilder.Append(" ");
					if (hours <= 9)
					{
						stringBuilder.Append("0");
					}
					stringBuilder.Append(hours);
					stringBuilder.Append(":");
					if (minutes <= 9)
					{
						stringBuilder.Append("0");
					}
					stringBuilder.Append(minutes);
					stringBuilder.Append(":");
					if (seconds <= 9)
					{
						stringBuilder.Append("0");
					}
					stringBuilder.Append(seconds);
					if (text2 != "")
					{
						stringBuilder.Append(".");
						stringBuilder.Append(text2);
					}
					return stringBuilder.ToString();
				}
				return "null";
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ToString, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ToString);
				}
			}
		}

		public override bool Equals(object obj)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.Equals);
			}
			try
			{
				if (obj == null || obj.GetType() != typeof(OracleIntervalDS))
				{
					return false;
				}
				return CompareTo(obj) == 0;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.Equals, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.Equals);
				}
			}
		}

		public override int GetHashCode()
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.GetHashCode);
			}
			try
			{
				if (m_bNotNull)
				{
					return m_byteRepresentation.GetHashCode();
				}
				return 0;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.GetHashCode);
				}
			}
		}

		internal byte[] ToBytes(string intervalStr)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ToBytes);
			}
			try
			{
				int num = 0;
				int num2 = 0;
				int num3 = 0;
				int num4 = 0;
				byte[] array = new byte[11];
				string text = intervalStr.Trim();
				char c = text[0];
				int num5 = ((c == '-' || c == '+') ? 1 : 0);
				if (1 == num5)
				{
					text = text.Substring(num5);
				}
				int num6 = text.IndexOf(' ');
				if (num6 < 0)
				{
					throw new FormatException();
				}
				string text2 = text.Substring(0, num6);
				if (text2.Length > m_dayPrec)
				{
					throw new FormatException();
				}
				int num7 = int.Parse(text2);
				string[] array2 = text.Substring(num6 + 1).Split(':');
				if (array2 != null && array2.Length == 3)
				{
					string s;
					string s2;
					string s3;
					string text3;
					try
					{
						s = array2[0];
						s2 = array2[1];
						string[] array3 = array2[2].Split('.');
						if (array3 == null || array3.Length == 0 || array3.Length > 2)
						{
							throw new FormatException();
						}
						s3 = array3[0];
						text3 = ((array3.Length != 2) ? "0" : array3[1]);
					}
					catch (Exception)
					{
						throw new FormatException();
					}
					num = int.Parse(s);
					num2 = int.Parse(s2);
					num3 = int.Parse(s3);
					if (num7 > 999999999 || num > 23 || num2 > 59 || num3 > 59)
					{
						throw new FormatException();
					}
					if (text3.Length <= MAXLEADPREC)
					{
						if (text3.Length != MAXLEADPREC)
						{
							text3 = text3.PadRight(MAXLEADPREC, '0');
						}
						num4 = int.Parse(text3);
						if (c == '-')
						{
							num7 = -num7;
							num = -num;
							num2 = -num2;
							num3 = -num3;
							num4 = -num4;
						}
						num7 += (int)INTERVALDAYOFFSET;
						array[0] = RepConversion.RightShiftFirstNibble(num7);
						array[1] = RepConversion.RightShiftSecondNibble(num7);
						array[2] = RepConversion.RightShiftThirdNibble(num7);
						array[3] = RepConversion.RightShiftFourthNibble(num7);
						array[4] = (byte)(num + INTERVALDSOFFSET);
						array[5] = (byte)(num2 + INTERVALDSOFFSET);
						array[6] = (byte)(num3 + INTERVALDSOFFSET);
						num4 += (int)INTERVALDAYOFFSET;
						array[7] = RepConversion.RightShiftFirstNibble(num4);
						array[8] = RepConversion.RightShiftSecondNibble(num4);
						array[9] = RepConversion.RightShiftThirdNibble(num4);
						array[10] = RepConversion.RightShiftFourthNibble(num4);
						return array;
					}
					throw new FormatException();
				}
				throw new FormatException();
			}
			catch (Exception ex2)
			{
				OracleException.HandleError(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ToBytes, ex2);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.ToBytes);
				}
			}
		}

		internal static int GetIDSData(byte[] byteRepresentation, byte idsComponent)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.GetIDSData);
			}
			try
			{
				int result = 0;
				switch (idsComponent)
				{
				case 2:
					if (byteRepresentation[4] > LDIREGIDFLAG)
					{
						result = RepConversion.LeftShiftThirdNibble(byteRepresentation[0]);
						result |= RepConversion.LeftShiftFourthNibble(byteRepresentation[1]);
						result -= (int)INTERVALDAYOFFSET_REGIDFLAG;
						RepConversion.GetRegHour(byteRepresentation[2]);
						RepConversion.GetRegMin(byteRepresentation[3]);
					}
					else
					{
						result = RepConversion.LeftShiftFirstNibble(byteRepresentation[0]);
						result |= RepConversion.LeftShiftSecondNibble(byteRepresentation[1]);
						result |= RepConversion.LeftShiftThirdNibble(byteRepresentation[2]);
						result |= RepConversion.LeftShiftFourthNibble(byteRepresentation[3]);
						result -= (int)INTERVALDAYOFFSET;
					}
					break;
				case 3:
					result = (int)((byteRepresentation[4] <= LDIREGIDFLAG) ? (byteRepresentation[4] - INTERVALDSOFFSET) : (byteRepresentation[4] - LDIREGIDSET));
					break;
				case 4:
					result = (int)(byteRepresentation[5] - INTERVALDSOFFSET);
					break;
				case 5:
					result = (int)(byteRepresentation[6] - INTERVALDSOFFSET);
					break;
				case 7:
					result = RepConversion.LeftShiftFirstNibble(byteRepresentation[7]);
					result |= RepConversion.LeftShiftSecondNibble(byteRepresentation[8]);
					result |= RepConversion.LeftShiftThirdNibble(byteRepresentation[9]);
					result |= RepConversion.LeftShiftFourthNibble(byteRepresentation[10]);
					result -= (int)INTERVALDAYOFFSET;
					break;
				}
				return result;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.GetIDSData, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.GetIDSData);
				}
			}
		}

		internal static void GetIDSData(byte[] byteRepresentation, out int days, out int hours, out int minutes, out int seconds, out int fseconds, int offset = 0)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.GetIDSData);
			}
			try
			{
				if (byteRepresentation[4 + offset] > LDIREGIDFLAG)
				{
					days = RepConversion.LeftShiftThirdNibble(byteRepresentation[offset]);
					days |= RepConversion.LeftShiftFourthNibble(byteRepresentation[1 + offset]);
					days -= (int)INTERVALDAYOFFSET_REGIDFLAG;
					RepConversion.GetRegHour(byteRepresentation[2 + offset]);
					RepConversion.GetRegMin(byteRepresentation[3 + offset]);
				}
				else
				{
					days = RepConversion.LeftShiftFirstNibble(byteRepresentation[offset]);
					days |= RepConversion.LeftShiftSecondNibble(byteRepresentation[1 + offset]);
					days |= RepConversion.LeftShiftThirdNibble(byteRepresentation[2 + offset]);
					days |= RepConversion.LeftShiftFourthNibble(byteRepresentation[3 + offset]);
					days -= (int)INTERVALDAYOFFSET;
				}
				if (byteRepresentation[4 + offset] > LDIREGIDFLAG)
				{
					hours = (int)(byteRepresentation[4 + offset] - LDIREGIDSET);
				}
				else
				{
					hours = (int)(byteRepresentation[4 + offset] - INTERVALDSOFFSET);
				}
				minutes = (int)(byteRepresentation[5 + offset] - INTERVALDSOFFSET);
				seconds = (int)(byteRepresentation[6 + offset] - INTERVALDSOFFSET);
				fseconds = RepConversion.LeftShiftFirstNibble(byteRepresentation[7 + offset]);
				fseconds |= RepConversion.LeftShiftSecondNibble(byteRepresentation[8 + offset]);
				fseconds |= RepConversion.LeftShiftThirdNibble(byteRepresentation[9 + offset]);
				fseconds |= RepConversion.LeftShiftFourthNibble(byteRepresentation[10 + offset]);
				fseconds -= (int)INTERVALDAYOFFSET;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.GetIDSData, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.GetIDSData);
				}
			}
		}

		internal static decimal IntervalDSToTicks(byte[] byteRepresentation)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.IntervalDSToTicks);
			}
			try
			{
				GetIDSData(byteRepresentation, out var days, out var hours, out var minutes, out var seconds, out var fseconds);
				return (decimal)days * new decimal(864000000000L) + (decimal)(hours * 36000000000L) + (decimal)((long)minutes * 600000000L) + (decimal)((long)seconds * 10000000L) + (decimal)((double)fseconds * 0.01);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.IntervalDSToTicks, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.IntervalDSToTicks);
				}
			}
		}

		internal static TimeSpan GetTimeSpan(byte[] byteRepresentation, OracleDbType oraType, int dataOffset = 0, int dataLength = -1)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.GetTimeSpan);
			}
			try
			{
				if (oraType != OracleDbType.IntervalDS)
				{
					throw new OracleTypeException(ResourceStringConstants.INT_ERR);
				}
				if (dataLength == -1)
				{
					dataLength = byteRepresentation.Length;
				}
				if (dataLength != 11)
				{
					throw new ArgumentException("byteRepresentation");
				}
				decimal num = default(decimal);
				GetIDSData(byteRepresentation, out var days, out var hours, out var minutes, out var seconds, out var fseconds, dataOffset);
				if (Math.Abs(fseconds) % 100 > 0)
				{
					throw new OverflowException();
				}
				num = (decimal)days * new decimal(864000000000L) + (decimal)(hours * 36000000000L) + (decimal)((long)minutes * 600000000L) + (decimal)((long)seconds * 10000000L) + (decimal)((double)fseconds * 0.01);
				if (num < new decimal(long.MinValue) || num > new decimal(long.MaxValue))
				{
					throw new OverflowException();
				}
				return new TimeSpan((long)num);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.GetTimeSpan, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.GetTimeSpan);
				}
			}
		}

		internal static OracleIntervalDS GetOracleIntervalDS(int days, int hours, int minutes, int seconds, int nanoseconds)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.GetOracleIntervalDS);
			}
			try
			{
				if ((days != 0) ? ((days >= 0) ? true : false) : ((hours != 0) ? ((hours >= 0) ? true : false) : ((minutes != 0) ? ((minutes >= 0) ? true : false) : ((seconds != 0) ? ((seconds >= 0) ? true : false) : ((nanoseconds >= 0) ? true : false)))))
				{
					if (nanoseconds < 0)
					{
						nanoseconds += 1000000000;
						seconds--;
					}
					if (seconds < 0)
					{
						seconds += 60;
						minutes--;
					}
					if (minutes < 0)
					{
						minutes += 60;
						hours--;
					}
					if (hours < 0)
					{
						hours += 24;
						days--;
					}
				}
				else
				{
					if (nanoseconds > 0)
					{
						nanoseconds -= 1000000000;
						seconds++;
					}
					if (seconds > 0)
					{
						seconds -= 60;
						minutes++;
					}
					if (minutes > 0)
					{
						minutes -= 60;
						hours++;
					}
					if (hours > 0)
					{
						hours -= 24;
						days++;
					}
				}
				return new OracleIntervalDS(days, hours, minutes, seconds, nanoseconds);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.GetOracleIntervalDS, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleIntervalDS, OracleTraceFuncName.GetOracleIntervalDS);
				}
			}
		}
	}
}
